import * as constants from './constants'
import axios from 'axios'

export const loginOut = () => ({
    type: constants.LOGIN_OUT,
    loginState: false
})

export const login = () => ({
    type: constants.LOGIN_IN,
    loginState: true
})

export const loginIn = (account, password) => {
    return (dispatch) => {
        axios.get(`/api/login.json?account=${account}&&password=${password}`).then(res => {
            if (res.data.data) {
                dispatch(login())
            }

        }).catch(err => err)
    }
}